bafdd4604d653504e90d62698c146781a4f50d5b,gateway/src/main/java/com/continuuity/gateway/tools/StreamClient.java,StreamClient,parseArguments,#String[]#,142

Before Change



  public boolean parseArguments(String[] args) {
    // parse generic args first
    CommandLineParser parser = new BasicParser();
    // Check all the options of the command line
    try {
      command = args[0];
      CommandLine line = parser.parse(options, args);
      parseBasicArgs(line);
      // returns false if help was passed
      if (help) {
        return false;
      }
      destination = line.getOptionValue(STREAM_OPTION, null);
      body = line.getOptionValue(BODY_OPTION, null);
      bodyFile = line.getOptionValue(BODY_FILE_OPTION, null);
      hex = line.hasOption(HEX_OPTION);
      urlenc = line.hasOption(URL_OPTION);
      all = line.hasOption(ALL_OPTION);
      if (line.hasOption(HEADER_OPTION)) {
        String[] headerList = line.getOptionValues(HEADER_OPTION);
        // must pass header arguments in pairs
        if (headerList.length % 2 != 0) {
          usage("--" + HEADER_OPTION + " arguments must be passed in pairs");
        }
        for (int i = 0; i < headerList.length; i += 2) {
          headers.put(headerList[i], headerList[i + 1]);
        }
      }
      // validate consumer is a numerical value
      consumer = line.hasOption(GROUP_OPTION) ? parseNumericArg(line, GROUP_OPTION).toString() : null;
      first = line.hasOption(FIRST_OPTION) ? parseNumericArg(line, FIRST_OPTION).intValue() : null;
      last = line.hasOption(LAST_OPTION) ? parseNumericArg(line, LAST_OPTION).intValue() : null;
      ttl = line.hasOption(TTL_OPTION) ? parseNumericArg(line, TTL_OPTION) : null;
      // expect at least 1 extra arg because of pos arg, the command to run
      if (line.getArgs().length > 1) {
        usage("Extra arguments provided");
      }
    } catch (ParseException e) {
      printUsage(true);
    } catch (IndexOutOfBoundsException e) {
      printUsage(true);
    }
    return true;
  }

  static List<String> supportedCommands =

After Change


  }

  @Override
  public boolean parseAdditionalArguments(CommandLine line) {
    destination = line.getOptionValue(STREAM_OPTION, null);
    body = line.getOptionValue(BODY_OPTION, null);
    bodyFile = line.getOptionValue(BODY_FILE_OPTION, null);
    hex = line.hasOption(HEX_OPTION);
    urlenc = line.hasOption(URL_OPTION);
    all = line.hasOption(ALL_OPTION);
    if (line.hasOption(HEADER_OPTION)) {
      String[] headerList = line.getOptionValues(HEADER_OPTION);
      // must pass header arguments in pairs
      if (headerList.length % 2 != 0) {
        usage("--" + HEADER_OPTION + " arguments must be passed in pairs");
      }
      for (int i = 0; i < headerList.length; i += 2) {
        headers.put(headerList[i], headerList[i + 1]);
      }
    }
    // validate consumer is a numerical value
    consumer = line.hasOption(GROUP_OPTION) ? parseNumericArg(line, GROUP_OPTION).toString() : null;
    first = line.hasOption(FIRST_OPTION) ? parseNumericArg(line, FIRST_OPTION).intValue() : null;
    last = line.hasOption(LAST_OPTION) ? parseNumericArg(line, LAST_OPTION).intValue() : null;
    ttl = line.hasOption(TTL_OPTION) ? parseNumericArg(line, TTL_OPTION) : null;
    // should have 1 arg remaining, the command which is positional
    String[] remaining = line.getArgs();
    if (remaining.length != 1) {
      return false;
    }
    command = remaining[0];
    return true;
  }

  static List<String> supportedCommands =